package com.sandking.util;

import java.util.Date;

/**
 * @UserName : SandKing
 * @DataTime : 2012-9-17 上午11:39:16
 * @Description ：Please describe this document
 */
@SuppressWarnings("serial")
public class SK_Date extends Date {

	public static final long TIME_MILLISECOND = 1;

	public static final long TIME_SECOND = 1000 * TIME_MILLISECOND;

	public static final long TIME_MINUTE = 60 * TIME_SECOND;

	public static final long TIME_HOUR = 60 * TIME_MINUTE;

	public static final long TIME_DAY = 24 * TIME_HOUR;

	public static final long TIME_WEEK = 7 * TIME_DAY;
	// 是否返回一个新对象
	private boolean isNew = false;

	public SK_Date() {
		super();
	}

	public SK_Date(boolean isNew) {
		super();
		this.isNew = isNew;
	}

	public SK_Date addWeek(int w) {
		return addMillisSecond(w * TIME_WEEK);
	}

	public SK_Date addDay(int d) {
		return addMillisSecond(d * TIME_DAY);
	}

	public SK_Date addHour(int h) {
		return addMillisSecond(h * TIME_HOUR);
	}

	public SK_Date addMinute(int m) {
		return addMillisSecond(m * TIME_MINUTE);
	}

	public SK_Date addSecond(int s) {
		return addMillisSecond(s * TIME_SECOND);
	}

	public SK_Date addMillisSecond(long t) {
		SK_Date sk_date = null;
		if (this.isNew) {
			sk_date = new SK_Date(isNew);
		} else {
			sk_date = this;
		}
		sk_date.setTime(this.getTime() + t);
		return sk_date;
	}
}
